home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 May: Tool Chest / Dev.CD May 98 TC.toast / Tool Chest / Development Kits / HyperCard Related / APDA HyperCard Toolkits / HyperCard Serial Toolkit 2.6 / Source Code / charsAvailable.p < prev    next >
Encoding:
Text File  |  1995-02-07  |  1.4 KB  |  63 lines  |  [TEXT/MPS ]

  1. (*
  2.     charsAvailable() -- Return the number of characters available for reading from the serial port.
  3.  
  4.     To compile and link this file using Macintosh Programmer's Workshop,
  5.  
  6.         pascal -w charsAvailable.p
  7.         link -m ENTRYPOINT -o HyperCommands -rt XFCN=7030 -sn Main=charsAvailable ∂
  8.             charsAvailable.p.o "{MPW}"Libraries:interface.o "{MPW}"Libraries:Libraries:HyperXLib.o
  9.  
  10.     © Copyright 1987,88,89 by Apple Computer, Inc.
  11.  
  12.     Initial coding 9/87 by Harry R. Chesley.
  13. *)
  14.  
  15. {$R-}
  16.  
  17. {$S charsAvailable }     { Segment name must be the same as the command name. }
  18.  
  19. unit DummyUnit;
  20.  
  21. interface
  22.  
  23. uses MemTypes, QuickDraw, OSIntf, HyperXCmd;
  24.  
  25. procedure EntryPoint(paramPtr: XCmdPtr);
  26.     
  27. implementation
  28.  
  29. procedure charsAvailable(paramPtr: XCmdPtr); forward;
  30.  
  31. procedure EntryPoint(paramPtr: XCmdPtr);
  32.  
  33.     begin
  34.         charsAvailable(paramPtr);
  35.     end;
  36.  
  37. procedure charsAvailable(paramPtr: XCmdPtr);
  38.  
  39.     var l: longInt;
  40.         s: Str255;
  41.  
  42.     procedure Fail(errMsg: Str255); { set theResult and quit }
  43.         begin
  44.             paramPtr^.returnValue := PasToZero(paramPtr,errMsg);
  45.             exit(charsAvailable);
  46.         end;
  47.  
  48.     {$I SPortUtil.inc}
  49.  
  50.     begin
  51.         if paramPtr^.paramCount <> 0 then Fail('parameter count is not 0');
  52.  
  53.         SetUpSPortGlobals;
  54.         EnsureOpenPort;
  55.  
  56.         { Get and return the character count from the port. }
  57.         if SerGetBuf(ThisSPort.portInDev,l) <> noErr then Fail('SerGetBuf failed');
  58.         LongToStr(paramPtr,l,s);
  59.         paramPtr^.returnValue := PasToZero(paramPtr,s);
  60.     end;
  61.  
  62. end.
  63.